#include <iostream>
#include <cstdlib>
#include <ctime>

using namespace std;

#define TOTAL 1000

int main() {
	cout << TOTAL << '\n';

	srand( time( 0 ) );

	int total = TOTAL;
	while ( total-- ) {
		int w = rand() % 11;
		int h = rand() % 11;

		cout << w << ' ' << h << '\n';

		for ( int fila = 0; fila < h; fila++ ) {
			for ( int col = 0; col < w; col++ ) {
				int nro = rand() % 9 + 1;
				cout << nro;
			}
			cout << '\n';
		}
	}

	return 0;
}
